<?php
/**
 * Object Relational Persistence Mapping Class for table: pha_provider
 *
 * @package	modules.dept_pharmacy.ordo
 * @author	viethd
 * @version $
 * @copyright 2009 LHV Company
 */
class PhaProvider extends ORDataObject {

	/**#@+
	 * Fields of table: pha_provider mapped to class members
	 */
	var $pha_provider_id		= '';
	var $name		= '';
	var $country_id		= '';
	var $phone		= '';
	var $fax		= '';
	var $email		= '';
	var $address		= '';
	var $website		= '';
	/**#@-*/


	/**
	 * DB Table
	 */
	var $_table = 'pha_provider';

	/**
	 * Primary Key
	 */
	var $_key = 'pha_provider_id';
	
	/**
	 * Internal Name
	 */
	var $_internalName = 'PhaProvider';

	/**
	 * Handle instantiation
	 */
	function __construct() {
		parent::ORDataObject();
	}
	/**
	 * List providers
	 * @return 
	 * if $short == true then result(pha_provider_id=>name)
	 * else result(pha_provider_id,name,
	 *  country,phone, fax, email, address, website)
	 */
	public function listProviders($short = false) {
	    $field    =   L10nHelper::changeField(L10nHelper::getLocale(), 'name');
        
        $ds =& new Datasource_sql();
        if ($short == false) {
            $sql = array(
                    'cols'  => "pha_provider_id, name, ct.$field country, phone, fax,
                                email, address, website",
                    'from'  => "$this->_table t 
                            INNER JOIN country ct ON (t.country_id = ct.country_id) 
                            "
                    );
            $ds->setup($this->_db, $sql);
            $result = $ds->toArray();        
            return $result;
        } else {
            $sql = array(
                    'cols'  => "pha_provider_id, name",
                    'from'  => "$this->_table"
                    );
            $ds->setup($this->_db, $sql);
            $result = $ds->toArray('pha_provider_id','name');        
            return $result;
            
        }
            
	}
	
}
?>
